﻿///<reference path="../ext/vswd-ext_2.0.2.js" />
var mapLayout;
var map;
var north;
var west;
var center;
var south;
var layoutItems = [];
var loadingMask;

var toolbarItems = [{ xtype: 'tbbutton', text: '放大', cls: 'x-btn-text-icon', icon: 'img/zoom-in.gif', tooltip: 'Fixed Zoom In', handler: function() { navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN); } },
					{ xtype: 'tbbutton', text: '缩小', cls: 'x-btn-text-icon', icon: 'img/zoom-out.gif', tooltip: 'Fixed Zoom Out', handler: function() { navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT); } },
					{ xtype: 'tbbutton', text: '漫游', cls: 'x-btn-text-icon', icon: 'img/esriPan.png', tooltip: 'Pan', handler: function() { navToolbar.deactivate(); } },
					{ xtype: 'tbbutton', text: '全图', cls: 'x-btn-text-icon', icon: 'img/full-extent.gif', tooltip: 'Shows the Full Extent of Map', handler: function() { navToolbar.zoomToFullExtent(); } },
					{ xtype: 'tbbutton', id: 'tbarMeasureButton', text: '测量', cls: 'x-btn-text-icon', icon: 'img/measure.gif', tooltip: 'Measurement Tool' },
					{ xtype: 'tbbutton', text: '书签', cls: 'x-btn-text-icon', icon: 'img/bmark.gif', tooltip: 'Bookmark Current View' },
					{ xtype: 'tbseparator' },
					{ xtype: 'tbbutton', id: 'tbarIdentityButton', text: '选择', cls: 'x-btn-text-icon', icon: 'img/drag-zoom.gif', tooltip: 'Identify Selected Layer Items', handler: function() { drawToolbar.activate(esri.toolbars.Draw.EXTENT); dojo.connect(drawToolbar, "onDrawEnd", identify); } },
					{ xtype: 'tbbutton', id: 'tbarQueryButton', text: '查询', cls: 'x-btn-text-icon', icon: 'img/attSelect.gif', tooltip: 'Query Layers by Attributes' },
					{ xtype: 'tbseparator' },
					{ xtype: 'tbbutton', id: 'tbarAddDataButton', text: '添加数据', cls: 'x-btn-text-icon', icon: 'img/add-data.gif', tooltip: 'Add Data/Services Over Google Maps' },
					{ xtype: 'tbseparator' },
					{ xtype: 'tbbutton', id: 'tbarSVButton', text: '街景', cls: 'x-btn-text-icon', icon: 'img/streetv.gif', tooltip: 'Shows the street view' },
					{ xtype: 'tbfill' },
					{ xtype: 'tbbutton', id: 'tbarOptionsButton', text: '选项', cls: 'x-btn-text-icon', icon: 'img/options.png', tooltip: 'Configure Mashup'}];

var coordinateBar = new Ext.ux.StatusBar({ id: 'coordinateBarID', defaultText: 'Coordinates' });

var statusBar = new Ext.ux.StatusBar({ id: 'mapStatusBarID', defaultText: 'Ready' });

var accordionItems = [{title:'图层列表',html:'<div id=\'treeViewLayers\'></div><div id=\'animationPoint\'></div>'},
					  {title:'工具箱', html:'<div id=\'toolboxPanel\'></div>'},
					  {title:'书签', html:'<div id=\'bookmarkPanel\'></div>'}];

var layerTree;

var tileLayers = new Array();

var mapLayers = new Array();

var layerTreeContextMenuAGS = new Ext.menu.Menu({ items: [{ text: '删除图层', cls: 'x-btn-text-icon', icon: 'img/removeLayer.gif', handler: deleteLayerTreeNode }, { text: '选项', cls: 'x-btn-text-icon', icon: 'img/properties.gif', handler: openLayerInfoWindow }, { text: '属性表', cls: 'x-btn-text-icon', icon: 'img/attribTable.gif', handler: getLayerAttributeTable }, { text: '缩放到图层', cls: 'x-btn-text-icon', icon: 'img/zoom2layer.gif', handler: zoom2AGSLayer}] });

var agsLayerExtents = new Array();

var esriGeomTypeArr = new Array();

var agsLayerFields = new Array();

var agsLayerColumns = new Array();

var agsLayerFieldsWS = new Array(); //without shapes

var agsLayerColumnsWS = new Array(); //without shapes

//Variables for Query and its Window started.
var agsQueryFields = new Array();

var fieldValueGridStore = null;

var fieldValueGrid = null;

var tempPanelItem = null;

var fieldValueGridPanel;

var selectedFieldColumn = '';

var tempQueryWindowItem = null;

var queryWindow = new Ext.Window({ title: 'Query Layer', closeAction: 'hide', width: 365 });

var shapeFieldStatus = true;

var attributeWindow = new Ext.Window({ title: '选择信息', closeAction: 'hide', width: 534 });

var tempWindowItem = null;

var esriGeometryService = 'http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer';

var navToolbar;

var drawToolbar;

//_onMouseUpHandler: function(evt) {
//var map = this.map;
//    rect = this._normalizeRect(this._start, evt.mapPoint, map.spatialReference);
//    map.graphics.remove(this._graphic, true);
//    if (rect.width === 0 && rect.height === 0) { return; }
//    if (this._navType === esri.toolbars.Navigation.ZOOM_IN) {
//        map.setExtent(esri.geometry._rectToExtent(new esri.geometry.Rect(rect)));
//    } else {
//        var tl = map.toScreen(rect),
//        tr = map.toScreen({ x: rect.x + rect.width, y: rect.y, spatialReference: map.spatialReference }), _9d2 = map.extent.getWidth(), _9d3 = (_9d2 * map.width) / Math.abs(tr.x - tl.x), _9d4 = (_9d3 - _9d2) / 2, ext = map.extent; map.setExtent(new esri.geometry.Extent(ext.xmin - _9d4, ext.ymin - _9d4, ext.xmax + _9d4, ext.ymax + _9d4, ext.spatialReference)); }
//}.
